<template>
	<view class="container">
		<view class="spacer" style="height: 5rpx;"></view>
		<up-search :placeholder="currentText" :show-action="false" actionText="搜索" borderColor="#c3c3c3"
			bgColor="#ffffff" :animation="true"></up-search>
		<!-- 纸制图书 -->
		<view v-if="bookList.length>0">
			<view class="spacer" style="height: 30rpx;"></view>
			<up-text size=18 :bold="true" text="纸制图书"></up-text>
			<view class="enlightenment" v-for="(item, index) in bookList" :key="index">
				<view @click="toBookDetails(item.id)" class="enlightenment_nav">
					<view style="margin-top: 20rpx;margin-right: 20rpx;width: 40%;">
						<up-image style="margin-top: 10rpx;" width="220rpx" height="300rpx" radius="20rpx"
							:show-loading="true" :src="item.url"></up-image>
					</view>
					<view style="margin-top: 20rpx; margin-right: 20rpx;width: 80vw;">
						<view class="spacer" style="height: 20rpx;"></view>
						<up-text :bold="true" size=18 :text="item.name"></up-text>
						<view class="spacer" style="height: 15rpx;"></view>
						<up-text size=10 :text="`[${item.category}] ${item.introduction}`"></up-text>
						<view class="spacer" style="height: 30rpx;"></view>
						<up-text :text="`书号: ${item.number}`"></up-text>
						<view class="spacer" style="height: 10rpx;"></view>
						<up-text :text="`作者:【${item.nationality}】${item.username}`"></up-text>
					</view>
				</view>
			</view>
		</view>
		<!-- 活动列表 -->
		<view v-if="activityList.length>0">
			<view class="spacer" style="height: 30rpx;"></view>
			<up-text size=18 :bold="true" text="活动列表"></up-text>
			<view class="enlightenment" v-for="(item, index) in activityList" :key="index">
				<view class="enlightenment_nav">
					<view class="box" v-if="item.status==1" v-bind:style="{ background: '#00aa00' }">
						<up-text color="#ffffff" size=15 align="center" text="报名中"></up-text>
					</view>
					<view class="box" v-else-if="item.status==2" v-bind:style="{ background: '#e70000' }">
						<up-text color="#ffffff" size=15 align="center" text="进行中"></up-text>
					</view>
					<view class="box" v-if="item.status==0" v-bind:style="{ background: '#b8b8b8' }">
						<up-text color="#ffffff" size=15 align="center" text="已结束"></up-text>
					</view>
					<view style="margin-top: 20rpx;margin-right: 20rpx;width: 40%;">
						<up-image style="margin-top: 10rpx;" width="220rpx" height="300rpx" radius="20rpx"
							:show-loading="true" :src="item.url"></up-image>
					</view>
					<view style="margin-top: 20rpx; margin-right: 20rpx;width: 80vw;">
						<view class="spacer" style="height: 20rpx;"></view>
						<up-text :bold="true" size=18 :text="item.name"></up-text>
						<view class="spacer" style="height: 15rpx;"></view>
						<up-text size=10 :text="`活动时间:${item.time}`"></up-text>
						<view class="spacer" style="height: 30rpx;"></view>
						<up-text :text="item.introduction"></up-text>
					</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				currentText: '请输入书名/作者/ISBN/活动名称',
				// 书籍列表
				bookList: [{
					id: 1,
					url: "https://img.zcool.cn/community/011f075ebd771aa801214814eab377.jpg@1280w_1l_2o_100sh.jpg",
					name: "符号帝国",
					category: "历史",
					nationality: "法",
					introduction: "张媛教授推荐",
					number: "132131231",
					username: "罗兰巴尔德"
				}],
				// 活动列表
				activityList: [{
					id: 1,
					url: "https://img.zcool.cn/community/011f075ebd771aa801214814eab377.jpg@1280w_1l_2o_100sh.jpg",
					name: "全民读好书",
					status: 0,
					time: "2024年6月21日",
					introduction: "11位主持人和特邀连线嘉宾一起直播读书带货，给有需要的孩子捐赠书本。"
				}, {
					id: 2,
					url: "https://img.zcool.cn/community/01d8965c739ea7a801213f26d3604d.png@1280w_1l_2o_100sh.png",
					name: "荆棘鸟书会",
					status: 2,
					time: "2024年6月21日",
					introduction: "一个人在美丽纷繁的野外行走，因为自我中心的限制，无法看到周身瑰丽景色。"
				}, {
					id: 3,
					url: "https://ts1.cn.mm.bing.net/th/id/R-C.d65fc2bdb85e811df3b7d55de9949bb8?rik=rzgNwpd3cIQTzQ&riu=http%3a%2f%2fimg95.699pic.com%2fdesgin_photo%2f40100%2f2620_detail.jpg!detail860%2ffw%2f820%2fcrop%2f0x1309a0a0%2fquality%2f90&ehk=wWophK2LKW%2blLqktL9WRIOmAmSy3yqVybPM16lSax48%3d&risl=&pid=ImgRaw&r=0",
					name: "创意世界读书日",
					status: 1,
					time: "2024年6月21日",
					introduction: "读一本好书",
				}],
			}
		},
		methods: {
			toBookDetails(id) {
				uni.navigateTo({
					url: `/pages/bookdetails/bookdetails?id=${id}`
				});
			},
		}
	}
</script>

<style lang="scss">
	.container {
		padding: 10rpx;
		margin: 10rpx;
	}

	.spacer {
		background-color: transparent;
	}


	.enlightenment {
		padding: 10rpx;
		margin: 10rpx;
		width: 90vw;
		height: 340rpx;
		background: #ffffff;
		border-radius: 20rpx;
		margin-top: 30rpx;
		box-shadow: 4rpx 4rpx 7rpx 7rpx rgba(0, 0, 0, 0.1);
	}

	.enlightenment_nav {
		display: flex;
		margin-left: 20rpx;
	}

	.box {
		position: absolute;
		transform: translate(550%, 100%);
		width: 100rpx;
		height: 40rpx;
		border-radius: 0px 50rpx 50rpx 0rpx;
		/* border-radius的值为容器宽度的一半 */
	}
</style>